import type { PostPatientConsultOrderParams } from '@/types/consult'
import { defineStore } from 'pinia'
import { ref } from 'vue'

//通过类型别名，保存问诊信息类型，方便复用
export type IllnessInfoType = Pick<
  PostPatientConsultOrderParams,
  'illnessDesc' | 'illnessTime' | 'consultFlag' | 'pictures'
>



// 问诊信息
export const useConsultStore = defineStore(
  'consult',
  () => {
    // 病情描述
    const initValue: IllnessInfoType = {
      illnessDesc: '',
      illnessTime: 2,
      consultFlag: 1,
      pictures: [],
    }

    // 病情描述
    const illnessInfo = ref<IllnessInfoType>({ ...initValue })

     // 问诊类型，医院类型，科室id
    const type = ref('')
    const illnessType = ref('')
    const depId = ref('')

    //患者ID
    const patientId = ref('')

     // 重置store数据
    const reset = ()=>{
      illnessInfo.value = {...initValue}
      type.value = ''
      illnessType.value=''
      depId.value = ''
      patientId.value=''
    } 

    return { illnessInfo, type, illnessType, depId, patientId,reset }
  },
  {
    // 持久化
    persist: true,
  }
)
